package gov.army.workshop.baseworkshop.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;


@Entity
@Table(name="EQMS_WORKITEM")

public class WorkItem extends BaseObject {
	/**
	 * 
	 */
	private static final long serialVersionUID = 4832229787994880206L;
	private Long id;
	private String partNumber;
	private String nomenclature;
	private int quantity;
	private String natureOfWork;
	private String remark;
	private Workorder workorder;

	@Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Long getId() {
        return id;
    }
    
	/**
	 * @param id the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}
	/**
	 * @return the partNumber
	 */
	@Column(name = "PART_NUMBER", nullable = false)
    
	public String getPartNumber() {
		return partNumber;
	}

	/**
	 * @return the nomenclature
	 */
	@Column(name = "NOMENCLATURE")
    
	public String getNomenclature() {
		return nomenclature;
	}

	/**
	 * @return the quantity
	 */
	@Column(name = "QUANTITY")
    
	public int getQuantity() {
		return quantity;
	}

	/**
	 * @return the natureOfWork
	 */
	@Column(name = "NATURE_OF_WORK")
    
	public String getNatureOfWork() {
		return natureOfWork;
	}

	/**
	 * @return the remark
	 */
	@Column(name = "REMARKS")
    
	public String getRemark() {
		return remark;
	}

	/**
	 * @return the workorder
	 */
	@ManyToOne( fetch=FetchType.EAGER )
    @JoinColumn(name="WORKORDER_ID", nullable=false)
	public Workorder getWorkorder() {
		return workorder;
	}

	/**
	 * @param workorder the workorder to set
	 */
	public void setWorkorder(Workorder workorder) {
		this.workorder = workorder;
	}

	/**
	 * @param partNumber
	 *            the partNumber to set
	 */
	public void setPartNumber(String partNumber) {
		this.partNumber = partNumber;
	}

	/**
	 * @param nomenclature
	 *            the nomenclature to set
	 */
	public void setNomenclature(String nomenclature) {
		this.nomenclature = nomenclature;
	}

	/**
	 * @param quantity
	 *            the quantity to set
	 */
	public void setQuantity(int quantity) {
		this.quantity = quantity;
	}

	/**
	 * @param natureOfWork
	 *            the natureOfWork to set
	 */
	public void setNatureOfWork(String natureOfWork) {
		this.natureOfWork = natureOfWork;
	}

	/**
	 * @param remark
	 *            the remark to set
	 */
	public void setRemark(String remark) {
		this.remark = remark;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		WorkItem other = (WorkItem) obj;
		if (natureOfWork == null) {
			if (other.natureOfWork != null)
				return false;
		} else if (!natureOfWork.equals(other.natureOfWork))
			return false;
		if (nomenclature == null) {
			if (other.nomenclature != null)
				return false;
		} else if (!nomenclature.equals(other.nomenclature))
			return false;
		if (partNumber == null) {
			if (other.partNumber != null)
				return false;
		} else if (!partNumber.equals(other.partNumber))
			return false;
		if (quantity != other.quantity)
			return false;
		if (remark == null) {
			if (other.remark != null)
				return false;
		} else if (!remark.equals(other.remark))
			return false;
		return true;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((natureOfWork == null) ? 0 : natureOfWork.hashCode());
		result = prime * result
				+ ((nomenclature == null) ? 0 : nomenclature.hashCode());
		result = prime * result
				+ ((partNumber == null) ? 0 : partNumber.hashCode());
		result = prime * result + quantity;
		result = prime * result + ((remark == null) ? 0 : remark.hashCode());
		return result;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "WorkItem [partNumber=" + partNumber + ", nomenclature="
				+ nomenclature + ", quantity=" + quantity + ", natureOfWork="
				+ natureOfWork + ", remark=" + remark + "]";
	}
}
